package com.teamone.etl.enterprise.controller;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.teamone.etl.enterprise.entity.AlarmPhone;
import com.teamone.etl.enterprise.service.AlarmPhoneService;
import com.teamone.etl.exception.CustomException;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;

/**
 预警号码(AlarmPhone)表控制层

 @author makejava
 @since 2021-01-21 11:30:13 */
@RestController
@RequestMapping("/alarmPhone")
public class AlarmPhoneController extends ApiController {
    /**
     服务对象
     */
    @Resource
    private AlarmPhoneService alarmPhoneService;

    @GetMapping("/{enterpriseId}")
    public R<List<AlarmPhone>> getList(@PathVariable(name = "enterpriseId") Integer enterpriseId){
        return success(alarmPhoneService.getList(enterpriseId));
    }

    @PostMapping
    public R<Boolean> add(@RequestBody AlarmPhone alarmPhone) throws CustomException {
        return success(alarmPhoneService.add(alarmPhone) > 0);
    }

    @DeleteMapping("/{id}")
    public R<Boolean> delete(@PathVariable(name = "id") Integer id){
        return success(alarmPhoneService.delete(id) > 0);
    }
}